package hang.xipujewelWeb.utils;

import hang.xipujewelWeb.dto.Dto;

import java.util.Map;

public class SearchDtoUtil {

	public static Dto intitDto(Map<String, Object> searchParams) {
		Dto dto = new Dto();
		String holdType = (String) searchParams.get("holdType");
		String order = (String) searchParams.get("order");
		String shape = (String) searchParams.get("shape");
		String color = (String) searchParams.get("color");
		String cut = (String) searchParams.get("cut");
		String neatness = (String) searchParams.get("neatness");
		String buffing = (String) searchParams.get("buffing");
		String fluorescence = (String) searchParams.get("fluorescence");
		String card = (String) searchParams.get("card");
		String symmetry = (String) searchParams.get("symmetry");
		String num = (String) searchParams.get("num");
		String cardId = (String) searchParams.get("cardId");
		String startPrice = (String) searchParams.get("startPrice");
		String endPrice = (String) searchParams.get("endPrice");
		String startWeight = (String) searchParams.get("startWeight");
		String endtWeight = (String) searchParams.get("endWeight");

		if (holdType != null && !"".equals(holdType)) {
			dto.setHoldType(holdType);
		}
		if (order != null && !"".equals(order)) {
			dto.setOrder(order);
		}
		if (shape != null && !"".equals(shape)) {
			dto.setShape(shape);
		}
		if (color != null && !"".equals(color)) {
			dto.setColor(color);
		}
		if (cut != null && !"".equals(cut)) {
			dto.setCut(cut);
		}
		if (neatness != null && !"".equals(neatness)) {
			dto.setNeatness(neatness);
		}
		if (buffing != null && !"".equals(buffing)) {
			dto.setBuffing(buffing);
		}
		if (fluorescence != null && !"".equals(fluorescence)) {
			dto.setFluorescence(fluorescence);
		}
		if (card != null && !"".equals(card)) {
			dto.setCard(card);
		}
		if (symmetry != null && !"".equals(symmetry)) {
			dto.setSymmetry(symmetry);
		}
		if (num != null && !"".equals(num)) {
			dto.setNum(num);
		}
		if (cardId != null && !"".equals(cardId)) {
			dto.setCardId(cardId);
		}
		if (startPrice != null && !"".equals(startPrice)) {
			dto.setStartPrice(Integer.parseInt(startPrice));
		}
		if (endPrice != null && !"".equals(endPrice)) {
			dto.setEndPrice(Integer.parseInt(endPrice));
		}
		if (startWeight != null && !"".equals(startWeight)) {
			dto.setStartWeight(Float.parseFloat(startWeight));
		}
		if (endtWeight != null && !"".equals(endtWeight)) {
			dto.setEndWeight(Float.parseFloat(endtWeight));
		}

		return dto;

	}

}
